<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    .box{
        width: 400px;
        height: 75px;
        margin: 0 auto;
    }
    .item{
        width: 20%;
        height: 100%;
        float: left;
        background: black;
        color: white;
        border-radius: 5px;
        margin: 10px;
        text-align: center;
        font-size: 18px;
        line-height: 4;
    }
</style>
<body>
<div class="box">
    <div class="item day">天</div>
    <div class="item hour">时</div>
    <div class="item minute">分</div>
    <div class="item second">秒</div>
</div>
<script>
    var day = document.querySelector('.day');
    var hour = document.querySelector('.hour');
    var minute = document.querySelector('.minute');
    var second = document.querySelector('.second');
    var inputTime = + new Date('2019-9-1 24:00:00');    //返回用户输入的时间戳
    conutDown();
    setInterval(conutDown,1000);
    function conutDown() {
        var nowTime = +new Date();  //返回当前时间戳
        var times = (inputTime - nowTime) / 1000;   //times是剩余的秒数
        var d = parseInt(times / 60 / 60 / 24); //天
        d = d < 10 ? '0' + d : d;   //自动补0
        day.innerHTML = d;
        var h = parseInt(times / 60 / 60 % 24); //时
        h = h < 10 ? '0' + h : h;
        hour.innerHTML = h;
        var m = parseInt(times / 60 % 60);  //分
        m = m < 10 ? '0' + m : m;
        minute.innerHTML = m;
        var s = parseInt(times % 60);   //秒
        s = s < 10 ? '0' + s : s;
        second.innerHTML = s;
    }
</script>
</body>
</html>